#ifndef _RECEIVER_H_
#define _RECEIVER_H_

#include "file.h"
#include "folder.h"
#include "receivererror.h"

class QNetworkReply;

namespace Avd {

/**
 * Receiver class.
 * Handle XML replies from server.
 */

class Receiver : public QObject {
Q_OBJECT
public:
	void answerLogin(const QString& input) throw(ReceiverError);
	void answerLogoff(const QString& input) throw(ReceiverError);
	void answerDownload(const QString& input) throw(ReceiverError);
	void answerUpload(const QString& input) throw(ReceiverError);
	void answerList(const QString& input) throw(ReceiverError);
	void answerMove(const QString& input) throw(ReceiverError);
	void answerDelete(const QString& input) throw(ReceiverError);
	void answerCreateFolder(const QString& input) throw(ReceiverError);
	void answerCopy(const QString& input) throw(ReceiverError);
	void answerVersion(const QString& input) throw(ReceiverError);
	
public slots:
	/** Main function.
	 * Receive a XML, identify which function should really receive and pass it.
	 */
	void receive(QNetworkReply * reply) throw(ReceiverError);

signals:
	void sigLogin(unsigned int status, unsigned int session);
	void sigLogoff(unsigned int status);
	void sigDownload(unsigned int status, File& file, unsigned int part = 0, unsigned int totalParts = 1);
	void sigUpload(unsigned int status, File& file);
	void sigList(unsigned int status, const QString& path, QList<File> files, QList<Folder> folders);
	void sigMove(unsigned int status, const QString& oldPath, const QString& newPath);
	void sigDelete(unsigned int status, QString& fullpath);
	void sigCreateFolder(unsigned int status, const Folder& folder);
	void sigCopy(unsigned int status, const QString& path, const File& file);
	void sigVersion(unsigned int status, const File& file);

};



}

#endif
